<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>停用物业公司</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">

    </style>
    <script type="text/css">
        body{text-align:center;}
    </script>
</head>

<body>
    <div style="position:absolute;top:20%;left:5%;width:80%;height:80%">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">物业公司</label>
                <div class="layui-input-block">
                    <span class="layui-form-label" id="areaname"></span>
                </div>
            </div>
            <div class="layui-form-item" style="display:none">
                <input style="width:90%" id="id" type="text" name="id" class="layui-input">
            </div>
            <div></div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">开始服务日期</label>
                <div class="layui-input-block">
                    <span class="layui-form-label" id="bdate"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">结束服务日期</label>
                <div class="layui-input-block">
                    <input style="width:50%" id="odate" type="text" name="odate" required lay-verify="required" placeholder="请选择日期" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div></div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">备注</label>
                <div class="layui-input-block">
                    <span class="layui-form-label" id="memo"></span>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn " lay-submit lay-filter="add">停用</button>
                        <button class="layui-btn layui-btn-primary" id="close">取消</button>
                    </div>
                </div>
            </div>
        </div>
        <script src="../../layuiadmin/layui/layui.js"></script>
        <script>
            layui.config({
                base: '../../layuiadmin/' //静态资源所在路径
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index', 'user'], function() {
                var $ = layui.$,
                    setter = layui.setter,
                    admin = layui.admin,
                    form = layui.form,
                    router = layui.router(),
                    search = router.search;

                form.render();

                //提交
                var mindate = $("#bdate").html();
                layui.use('laydate', function() {
                    var laydate = layui.laydate;
                    //执行一个laydate实例
                    laydate.render({
                        elem: '#odate', //指定元素
                        min: mindate,
                        theme: 'molv'
                    });
                });

                form.on('submit(add)', function(obj) {

                    admin.req({
                        url: "../../../Area/delex",
                        type: "post",
                        datatype: "json",
                        data: obj.field,
                        success: function(res) {
                            if (res.data == "ok") {
                                layer.msg('停用成功', {
                                    offset: 'auto',
                                    icon: 1,
                                    time: 1500,
                                    end: function() {
                                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                        parent.layer.close(index); // 关闭layer
                                        window.parent.location.reload(); //刷新父页面
                                    }
                                })
                            } else if (res.data == '无权限') {
                                layer.msg('没有权限，停用失败', {
                                    offset: 'auto',
                                    icon: 2,
                                    time: 1000,
                                    end: function() {
                                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                        parent.layer.close(index);
                                    }
                                })
                            } else {
                                layer.msg('停用失败', {
                                    offset: 'auto',
                                    icon: 2,
                                    time: 1000
                                })
                            }
                        },

                        error: function(res) {
                            layer.msg('停用失败', {
                                offset: 'auto',
                                icon: 2,
                                time: 1000
                            })
                        }
                    })

                });
                $("#close").on("click", function() {
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index); // 关闭layer
                });
            });
        </script>

</body>

</html>